import { defHttp } from '@/apis/http'
import type { CommonAPI } from '@/apis/schema/all'

/**
 * @description: 版本
 */

/** 获取安装脚本 */
export const getApiNodeInstallApi: CommonAPI<'/api/node/install', 'get'> = (
  params
) => defHttp.get(`/api/node/install`, { params })

/** 获取版本详情 */
export const getApiNodeVersionDetailApi: CommonAPI<
  '/api/node/version/info',
  'get'
> = (params) => defHttp.get(`/api/node/version/info`, { params })

/** 获取安装命令 */
export const getApiNodeVersionCommandApi: CommonAPI<
  '/api/node/install-command',
  'get'
> = (params) => defHttp.get(`/api/node/install-command`, { params })

/** 获取版本说明 */
export const getApiNodeVersionImprintApi: CommonAPI<
  '/api/node/version/imprint',
  'get'
> = (params) => defHttp.get(`/api/node/version/imprint`, { params })

/** 获取版本列表 */
export const getApiNodeVersionQueryListApi: CommonAPI<
  '/api/node/version/query',
  'get'
> = (params) => defHttp.get(`/api/node/version/query`, { params })

/** 切换版本 */
export const updateApiNodeVersionSwitchApi: CommonAPI<
  '/api/node/version/switch',
  'put'
> = (data) => defHttp.put(`/api/node/version/switch`, { data })

/** 删除版本 */
export const deleteApiNodeVersionApi: CommonAPI<
  '/api/node/version',
  'delete'
> = (data) =>
  defHttp.delete(
    `/api/node/version/${data.id}`,
    { data },
    {
      isTransformResponse: false
    }
  )
